//! MySQL存储实现 (占位)

use async_trait::async_trait;
use nacos_core::{Storage, Result};
use std::collections::HashMap;

// 这是一个占位实现，以便项目可以编译。
// 完整的实现需要使用sqlx::MySqlPool。

#[derive(Debug)]
pub struct MysqlStorage;

impl MysqlStorage {
    pub async fn new(_connection_string: &str) -> std::result::Result<Self, String> {
        // 完整的实现:
        // use sqlx::mysql::MySqlPoolOptions;
        // let pool = MySqlPoolOptions::new().connect(connection_string).await
        //     .map_err(|e| e.to_string())?;
        // // Run migrations
        // Ok(Self { pool })
        tracing::warn!("MySQL storage is a placeholder and not fully implemented yet.");
        Err("MySQL storage is not fully implemented yet.".to_string())
    }
}

#[async_trait]
impl Storage for MysqlStorage {
    async fn get(&self, _key: &str) -> Result<Option<Vec<u8>>> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn put(&self, _key: &str, _value: &[u8]) -> Result<()> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn delete(&self, _key: &str) -> Result<()> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn scan(&self, _prefix: &str) -> Result<Vec<(String, Vec<u8>)>> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn batch_get(&self, _keys: &[String]) -> Result<HashMap<String, Vec<u8>>> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn batch_put(&self, _data: &HashMap<String, Vec<u8>>) -> Result<()> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn batch_delete(&self, _keys: &[String]) -> Result<()> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn exists(&self, _key: &str) -> Result<bool> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn keys(&self, _pattern: &str) -> Result<Vec<String>> {
        unimplemented!("MySQL storage is a placeholder")
    }
    async fn clear(&self) -> Result<()> {
        unimplemented!("MySQL storage is a placeholder")
    }
}
